/*
 * @Author: zheguo 3188606474@qq.com
 * @Date: 2024-04-15 22:40:28
 * @LastEditors: zheguo 3188606474@qq.com
 * @LastEditTime: 2024-04-24 11:09:36
 * @FilePath: \projectOne\myapp\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @Author: zheguo 3188606474@qq.com
 * @Date: 2024-04-15 22:40:28
 * @LastEditors: zheguo 3188606474@qq.com
 * @LastEditTime: 2024-04-21 18:27:55
 * @FilePath: \ProjectAction\projectOne\myapp\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
    {
        path: "/shop",
        component: () => import("../views/Shop.vue"),
        children: [
            {
                path: "/shop/list",
                component: () => import("../views/shop/shopList.vue")
            },
            {
                path: "/shop/list2",
                component: () => import("../views/shop/shopList2.vue")
            },
            {
                path: "/shop/service",
                component: () => import("../views/shop/Service.vue")
            },
            {
                path: "/shop/community",
                component: () => import("../views/shop/Community.vue")
            },
            {
                path: "/shop/detail/:myid",
                component: () => import("../views/shop/DetailView.vue")
            }
            ,
            {
                path: "/shop/orderby/baozhangfuwu",
                component: () => import("../views/shop/imgComponent/comOne.vue")
            },
            {
                path: "/shop/orderby/qiyetuangou",
                component: () => import("../views/shop/imgComponent/comTwo.vue")
            },
            {
                path: "/shop/orderby/Fmatongdao",
                component: () => import("../views/shop/imgComponent/comThree.vue")
            },
            {
                path: "/shop/orderby/mifenka",
                component: () => import("../views/shop/imgComponent/comFour.vue")
            },
            {
                path: "/shop/orderby/yijiuhuanxin",
                component: () => import("../views/shop/imgComponent/comFive.vue")
            },
            {
                path: "/shop/orderby/huafeichongzhi",
                component: () => import("../views/shop/imgComponent/comSix.vue")
            },
            {
                path: "/shop",
                redirect: "/shop/list"
            }
        ]
    }
    ,
    {
        path: "/XiaomiWebsite",
        component: () => import("../views/Website.vue")
    }
    ,
    {
        path: "/HyperOS",
        component: () => import("../views/Hyeros.vue")
    }
    ,
    {
        path: "/openPlatform",
        component: () => import("../views/PlatForm.vue")
    }
    ,
    {
        path: "/youpin",
        component: () => import("../views/Youpin.vue")
    }
    ,
    {
        path: "/yunfuwu",
        component: () => import("../views/Yunfuwu.vue")
    },
    {
        path: "/Allin/:myid",
        component: () => import("../views/Allin.vue"),
    },
    {
        path: "/information",
        component: () => import("../views/Information.vue")
    },
    {
        path: "/030529/xiaomi/admin",
        name: "admin",
        component: () => import("../views/xiaomiAdmin.vue")
    }
    ,
    {
        path: "/admin/login",
        name: "login",
        component: () => import("../views/adminLogin/loginDialog.vue")
    },
    {
        path: "/",
        redirect: "/shop"
    }
]
const router = createRouter({
    history: createWebHistory(),
    routes,

})

router.beforeEach((to, from, next) => {
    let isToken = localStorage.getItem("token")

    if (to.name === "admin" && !isToken) {
        next({ name: "login" })
    } else if (to.name !== "admin") {
        localStorage.removeItem("token")
        next()
    }
    else {
        next()
    }
})
export default router
